package com.atguigu.spzx.manager.service.impl;


import com.atguigu.spzx.manager.mapper.SysUserMapperZxw;
import com.atguigu.spzx.manager.service.SysUserServiceZxw;


import com.atguigu.spzx.model.dto.system.SysUserDto;
import com.atguigu.spzx.model.entity.system.SysUser;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SysUserServiceImplZxw implements SysUserServiceZxw {
    @Autowired
    private SysUserMapperZxw sysUserMapperZxw;

    @Override
    public PageInfo<SysUser> findSysUserByPage(Integer pageNum, Integer pageSize, SysUserDto sysUserDto) {
        // 设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        List<SysUser> sysUserByPage = sysUserMapperZxw.findSysUserByPage(sysUserDto);
        PageInfo<SysUser> sysUserPageInfo = new PageInfo<>(sysUserByPage);
        System.out.print("\33[44;1m"+sysUserPageInfo+"\n\33[0m");
        // 获取分页数据
        int currentPage = sysUserPageInfo.getPageNum();
        int totalPages = sysUserPageInfo.getPages();
        long totalData = sysUserPageInfo.getTotal();

        System.out.println("当前页：" + currentPage);
        System.out.println("总页数：" + totalPages);
        System.out.println("总数据量：" + totalData);
        return sysUserPageInfo;
    }

    @Override
    public void saveSysUser(SysUser sysUser) {
        sysUserMapperZxw.saveSysUser(sysUser);
    }
}
